package controllers.sensors;

import play.Logger;
import controllers.exceptions.InvalidManufacturerException;
import controllers.persist.REMSPersist;
import controllers.sensors.implementation.tinkerforge.TFConfig;
import controllers.sensors.implementation.tinkerforge.TFSensorController;
import controllers.sensors.interfaces.SensorConfig;
import controllers.sensors.interfaces.SensorController;

public class SensorControllerFactory {

    public enum SensorManufacturer {
        TINKERFORGE;
    }

    private SensorManufacturer manufacturer;
    private TFSensorController tfSensorController;

    public SensorControllerFactory(SensorManufacturer manufacturer) {
        this.manufacturer = manufacturer;
    }

    public SensorController getSensorController(SensorConfig config) {
        switch (manufacturer) {
        case TINKERFORGE:
            if (this.tfSensorController == null) {
                this.tfSensorController = new TFSensorController(config);
            }
            return this.tfSensorController;
        }
        InvalidManufacturerException ex = new InvalidManufacturerException();
        Logger.error(ex, "Invalid Manufacturer: %s", manufacturer);
        throw ex;
    }

}
